import UIKit

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

    var window: UIWindow?

    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        guard let windowScene = (scene as? UIWindowScene) else { return }
        
        // 创建窗口实例
        let window = UIWindow(windowScene: windowScene)
        
        // 创建登录视图控制器
        let loginViewController = LoginViewController()
        
        // 创建导航控制器（可选，如果需要导航功能）
        let navigationController = UINavigationController(rootViewController: loginViewController)
        
        // 设置窗口的根视图控制器
        window.rootViewController = navigationController // 或直接使用 loginViewController
        
        // 设置并显示窗口
        self.window = window
        window.makeKeyAndVisible()
    }

    func sceneDidDisconnect(_ scene: UIScene) {
        // Called when the scene is being being destroyed.
        // This occurs shortly after the scene enters the background, or when its session is being discarded.
        // Release any resources associated with this scene that can be re-created the next time the scene connects.
        // The scene may re-connect later, as its session was not necessarily being discarded (see `application:didDiscardSceneSessions` instead).
    }

    func sceneDidBecomeActive(_ scene: UIScene) {
        // Called when the scene has become active.
        // Use this method to restart any tasks that were paused (or not yet started) when the scene was being inactive.
    }

    func sceneWillResignActive(_ scene: UIScene) {
        // Called when the scene is being being inactive.
        // This may occur due to temporary interruptions (ex. an incoming phone call).
    }

    func sceneWillEnterForeground(_ scene: UIScene) {
        // Called when the scene is about to enter the foreground.
        // Use this method to undo the changes made on entering the background.
    }

    func sceneDidEnterBackground(_ scene: UIScene) {
        // Called when the scene is being being destroyed.
        // This occurs shortly after the scene enters the background, or when its session is being discarded.
        // Release any resources associated with this scene that can be re-created the next time the scene connects.
        // The scene may re-connect later, as its session was not necessarily being discarded (see `application:didDiscardSceneSessions` instead).
    }
} 